package com.timerdemo;

import android.os.Handler;

import java.lang.ref.WeakReference;

/**
 * Created by lgs on 2018/3/8.
 * 解决Handler内存泄漏的方案
 * 1、Handler弱引用
 * 2、在视图销毁时将消息删除，mHandler.removeCallsAndMessages(null);
 */

public class UIHandler<T> extends Handler {

    private WeakReference<T> weakReference;

    public UIHandler(T t) {
        this.weakReference = new WeakReference<>(t);
    }

    public WeakReference<T> getWeakReference() {
        return weakReference;
    }
}
